/**
 * 非空更新
 * @param from
 * @param to
 */
// let updateNotNull = function (to, from) {
//   Object.keys(from).forEach((key) => {
//     if (from[key] !== undefined) {
//       to[key] = from[key]
//     }
//   })
// }
export default {
  /**
   * 更新title
   */
  pb_updateTitle (state, obj) {
    state.title = obj
  },
  updateToggleValue (state, value) {
    state.toggleValue = value
    // updateNotNull(state.toggleValue, value)
  },
  updatGraphicValue (state, value) {
    state.graphicValue = value
  },
  /*
   * 更新chartList
   */
  pb_updateChartList (state, arr) {
    state.chartList = []
    arr.forEach(obj => {
      state.chartList.push(obj)
    })
  },
  /**
   * 更新用户名
   */
  updateusername (state, value) {
    state.username = value
  },
  userId (state, value) {
    state.userid = value
  },
  /**
   * 更新时间
   */
  updatetime (state, value) {
    state.time = value
  },
  // 角色管理 菜单选择
  checkedMenuList (state, payload) {
    state.checkedMenuList = payload
  },
  // 更新用户详情
  pb_updateUserDetailObj (state, obj) {
    state.userDetailObj = obj
  },
  // 更新用户列表分页数据
  pb_updateCurrentPageData (state, obj) {
    state.currentPageData = obj
  },
  // 云智 切换系统类型
  pd_updateAppType (state, obj) {
    state.appType = obj
  },
  // 更新应用状态
  pd_updateAppId (state, str) {
    state.appId = str
    state.appId === '' ? window.sessionStorage.removeItem('appId') : window.sessionStorage.setItem('appId', state.appId)
  },
  // 更新应用信息
  pd_updateApp (state, obj) {
    state.appObj = obj
    state.appObj === null ? window.sessionStorage.removeItem('appObj') : window.sessionStorage.setItem('appObj', state.appObj)
  },
  updateBugListOpt (state, obj) {
    state.bugListOpt = obj
  },
  // 修改环境
  pd_updateExpEnv (state, obj) {
    state.expEnv = obj
  },
  // 修改路径
  pd_updatePath (state, obj) {
    state.path = obj
    if (!(document.cookie || navigator.cookieEnabled)) {
      console.warn('开启Cookie之后才能登录!')
      return
    }
    state.path === '' ? window.sessionStorage.removeItem('path') : window.sessionStorage.setItem('path', state.path)
  },
  // 更新系统编号
  pd_updateSysNo (state, num) {
    state.sysNo = num
    state.sysNo === '' ? window.sessionStorage.removeItem('sysNo') : window.sessionStorage.setItem('sysNo', state.sysNo)
  },
  // 移动开发平台切换工作区
  pd_updateWorkspaceId (state, obj) {
    state.workspaceId = obj
    state.workspaceId === '' ? window.sessionStorage.removeItem('workspaceId') : window.sessionStorage.setItem('workspaceId', state.workspaceId)
  },
  // 移动开发平台切换工作区
  pd_updateWorkspaceName (state, obj) {
    state.workspaceName = obj
    state.workspaceName === '' ? window.sessionStorage.removeItem('workspaceName') : window.sessionStorage.setItem('workspaceName', state.workspaceName)
  },
  // 客户标签
  updateCustTags (state, obj) {
    state.custTags = obj
  },
  updateselectTagPageNo (state, obj) {
    state.selectTagPageNo = obj
  },
  pb_updateSysName (state, val) {
    state.sysName = val
    window.sessionStorage.setItem('sysName', state.sysName)
  },
  v3_updateAppId (state, val) {
    state.v3AppId = val
    state.v3AppId === '' ? window.sessionStorage.removeItem('v3AppId') : window.sessionStorage.setItem('v3AppId', state.v3AppId)
  },
  v3_updatePlatform (state, val) {
    state.v3platform = val
    state.v3platform === '' ? window.sessionStorage.removeItem('v3platform') : window.sessionStorage.setItem('v3platform', state.v3platform)
  },
  v3_updateAppTitle (state, val) {
    state.v3AppTitle = val
    state.v3AppTitle === '' ? window.sessionStorage.removeItem('v3AppTitle') : window.sessionStorage.setItem('v3AppTitle', state.v3AppTitle)
  },
  v3_updateAppKey (state, val) {
    state.v3AppKey = val
    state.v3AppKey === '' ? window.sessionStorage.removeItem('v3AppKey') : window.sessionStorage.setItem('v3AppKey', state.v3AppKey)
  },
  v3_updateSecretKey (state, val) {
    state.v3SecretKey = val
    state.v3SecretKey === '' ? window.sessionStorage.removeItem('v3SecretKey') : window.sessionStorage.setItem('v3SecretKey', state.v3SecretKey)
  },
  // 诊断更新应用状态
  pd_updateBugAppId (state, str) {
    state.bugAppId = str
    state.bugAppId === '' ? window.sessionStorage.removeItem('bugAppId') : window.sessionStorage.setItem('bugAppId', state.bugAppId)
  },
  // 诊断更新应用信息
  pd_updateBugApp (state, obj) {
    state.bugAppObj = obj
    state.bugAppObj === '' ? window.sessionStorage.removeItem('bugAppObj') : window.sessionStorage.setItem('bugAppObj', state.bugAppObj)
  },
  pd_updateApplist (state, str) {
    state.appdatalist = str
    state.appdatalist === '' ? window.sessionStorage.removeItem('appdatalist') : window.sessionStorage.setItem('appdatalist', state.appdatalist)
  },
  v3_resresultList (state, str) {
    state.resresultList = str
    state.resresultList === '' ? window.sessionStorage.removeItem('resresultList') : window.sessionStorage.setItem('resresultList', state.resresultList)
  },
  v3_performpushId (state, str) {
    state.pushmsgId = str
    state.pushmsgId === '' ? window.sessionStorage.removeItem('pushmsgId') : window.sessionStorage.setItem('pushmsgId', state.pushmsgId)
  },
  v3_deleteAppId (state, str) {
    state.storageId = str
    state.storageId === '' ? window.sessionStorage.removeItem('storageId') : window.sessionStorage.setItem('storageId', state.storageId)
  }
  // 网关环境数据
  // updateGateWayResData (state, value) {
  //     state.gateWayResData = value
  // },
  // // 选中网关环境数据
  // selectGwData (state, value) {
  //     state.selectGwData = value
  // }
}
